import 'package:flutter/material.dart';

//调整child到设置的宽高比
class AspectRatioWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        title: new Text("AspectRatio"),
        leading: new BackButton(),
      ),
      body: new Container(
        color: Colors.amberAccent,
        height: 200,
        alignment: Alignment.topCenter,
        /* aspectRatio不能为null；
         * aspectRatio必须大于0；
         * aspectRatio必须是有限的。*/
        child: new AspectRatio(
          aspectRatio: 1.5,
          child: new Container(
            color: Colors.red,
          ),
        ),
      ),
    );
  }
}
